<?php
namespace app\business\controller;

use think\Controller;
use Util\SysDb;
use think\Db;
class Viplevel extends Controller
{
    public function getexpressfree()
    {
        $storeId = trim(input('param.expressSheetId'));
        $tenantId = trim(input('param.tenantId'));
       $level=trim(input('param.level'));
        // $this->db = new SysDb();
        // $admin = $this->db->table('goods_info')->join('as gi left join goods_store as gs on gi.store_id = gs.id left join tenant_goods_price as tgp on gi.id = tgp.gooods_id')->where(['store_id' => $storeId])->lists();
        $admin= Db::table('tenant_express_fee')
            ->alias(' tef')
            ->join('sys_express_fee sef', 'tef.express_fee_id = sef.id',"left")
            ->join('tenant_vip_level tvl', 'tvl.tenant_id = tef.tenant_id',"left")
            ->where(['express_sheet_id' => $storeId])
            ->where(['tef.tenant_id'=>$tenantId])
            ->where(['name'=>$level])
            ->field(array(' tef.id','tef.profit','tef.cost','sef.max_weight','sef.express_sheet_id'=>'expressSheetId',"tvl.discount","tvl.tenant_id"))
            ->select();

        if (!$admin) {
            exit(json_encode(['code' => 1, 'message' => 'error', "result" => "无库"]));
        } else {
            // $admin['price']=$admin['cost']+$admin['profit'];
          
           $admins['list']=$admin;
           $admins["risePrice"]=1;
           $this->db = new SysDb();
           $list = $this->db->table('tenant_vip_level')->where(['tenant_id' => $tenantId])->where(['condition_num' => 0])->lists();
           $lista = $this->db->table('tenant_vip_level')->where(['tenant_id' => $tenantId])->where(['condition_num' => 3])->lists();
           $lists=array();
           array_push($lists,$list[0]);
           array_push($lists,$lista[0]);
           $admins['viplist']=$lists;
            exit(json_encode(['message' => 'succ', 'result' => $admins]));
        }
    }
    public function viplist(){
        $storeId = trim(input('param.expressSheetId'));
        
    }
}
